<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    console.log("代码开始执行")
    var req = new XMLHttpRequest();  // 0

    req.open("get", "./13.php", true);  // 1

    req.send();  // 1

    req.onreadystatechange = function () {
        console.log("readyState", req.readyState);  // 2 3 4
        if (req.readyState == 4 && req.status == 200) {
            console.log(req.responseText);
            var data = JSON.parse(req.responseText);
            console.log(data);

            // 后端返回的响应数据 可以是 txt/html/xml/json数据(json字符串)
            // var result = req.responseText;
            // demo.innerHTML = result;
        }
    }
    console.log("代码开始结束")

</script>

</html>